package com.itcast.stargraph.controller;

import com.itcast.stargraph.dto.common.Result;
import com.itcast.stargraph.dto.request.UserLoginReqDTO;
import com.itcast.stargraph.dto.respone.UserLoginResDTO;
import com.itcast.stargraph.service.UserService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 *
 * @Author katana
 * @Date 2025/6/9 11:20
 */
@RestController
@RequestMapping("/api/1.0/user")
public class UserController {
    
    @Autowired
    private UserService userService;
    
    /**
     * 登录
     * @param loginDTO
     * @return
     */
    @PostMapping("/login")
    public Result<UserLoginResDTO> login(@RequestBody @Valid UserLoginReqDTO loginDTO) {
        return Result.ok(userService.login(loginDTO));
    }
}
